﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using T_vehicle.API.Application.Command.AccidentCommand;
using T_vehicle.API.Application.Command.ExpensesCommand;
using T_vehicle.API.Application.Command.IllegalCommand;
using T_vehicle.API.Application.Command.MaintenanceCommand;
using T_vehicle.API.Application.Command.RepairRecordsCommand;
using T_vehicle.API.Application.Command.TiresUsedCommand;

namespace T_vehicle.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RepairRecordsController : ControllerBase
    {
        private readonly IMediator mediator;

        public RepairRecordsController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 添加维修记录信息
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<int> AddRepair(AddRepairRecordsCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 删除维修记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpDelete]
        public async Task<int> DelRepair([FromQuery]DelRepairRecordsCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 批量删除维修记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> PDelRepair([FromQuery]PDelRepairRecordsCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 修改维修记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateRepair(UpdateRepairRecordsCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 添加保养记录信息
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<int> AddMainten(AddMaintenanceCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }



        /// <summary>
        /// 删除保养记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpDelete]
        public async Task<int> DelMainten([FromQuery]DelMaintenanceCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 批量删除保养记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpDelete]
        public async Task<int> PDelMainten([FromQuery] PDelMaintenanceCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 修改保养记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateMainten(UpdateMaintenanceCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 添加违章记录信息
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<int> AddIllgal(AddIllegalCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 删除违章记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpDelete]
        public async Task<int> DelIllgal([FromQuery]DelIllgalCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 批量删除违章记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpDelete]
        public async Task<int> PDelIllgal([FromQuery]PDelIllgalCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 修改违章记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateIllgal(UpdateIllegalCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 添加事故记录信息
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<int> AddAccident(AddAccidentCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 删除事故记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpDelete]
        public async Task<int> DelAccident([FromQuery]DelAccidentCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 批量删除事故记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> PDelAccident([FromQuery] PDelAccidentCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 修改事故记录信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateAccident(UpdateAccidentCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }



        /// <summary>
        /// 添加轮胎使用信息
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<int> AddTiresUsed(AddTiresUsedCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 删除轮胎信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpDelete]
        public async Task<int> DelTiresUserd([FromQuery] DelTiresUsedCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 批量删除使用轮胎信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> PDelTiresUserd([FromQuery] PDelTiresUsedCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 修改轮胎使用信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateTires(UpdateTiresUsedCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 添加新增费用信息
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<int> AddExpenses(AddExpensesCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 删除新增费用信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpDelete]
        public async Task<int> DelExpenses([FromQuery] DelExpensesCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 批量删除新增费用信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpDelete]
        public async Task<int> PDelExpenses( [FromQuery]PDelExpensesCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 修改使用费用信息 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateExpenses(UpdateExpensesCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }

    }
}
